package com.example.factory.api.controller.reporter;

import com.example.factory.api.dto.DtoReport;
import com.example.factory.api.dto.DtoReporterReport;
import com.example.factory.api.dto.Response;
import com.example.factory.api.dto.form.DtoReporterReportForm;
import com.example.factory.api.facade.ReportFacade;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Lei Tao
 */
@RestController
@RequestMapping("/reporter/report")
public class ReporterController {
    private final ReportFacade reportFacade;

    public ReporterController(ReportFacade reportFacade) {
        this.reportFacade = reportFacade;
    }

    @GetMapping("/{reporterGuid}/list")
    public Response<List<DtoReport>> list(@PathVariable("reporterGuid") String  reporterGuid) {
        return reportFacade.listByDtoReporterGuid(reporterGuid);
    }

    @GetMapping("/{reportGuid}/details")
    public Response<DtoReporterReport> reportDetails(@PathVariable("reportGuid")String reportGuid){
        return reportFacade.reportDetails(reportGuid);
    }

    @PostMapping("/commit")
    public Response<Void> commit(@RequestBody DtoReporterReportForm dtoReporterReportForm){
         return reportFacade.commit(dtoReporterReportForm);
    }
}
